package dongbai.soft.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import dongbai.soft.dao.GoodOrderDao;
import dongbai.soft.entity.GoodOrderEntity;
import dongbai.soft.service.GoodOrderService;
import dongbai.soft.utils.PageUtils;
import dongbai.soft.utils.Query;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("goodOrderService")
@SuppressWarnings("unchecked")
public class GoodOrderServiceImpl extends ServiceImpl<GoodOrderDao, GoodOrderEntity> implements GoodOrderService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Map<String, Object> filter = (Map<String, Object>) params.get("filter");
        QueryWrapper<GoodOrderEntity> wrapper = new QueryWrapper<>();
        if (filter.get("type").equals("0")) {
            wrapper.le("type", 1);
        } else {
            wrapper.eq("type", 2);
        }
        IPage<GoodOrderEntity> page = this.page(
                new Query<GoodOrderEntity>().getPage(params),
                wrapper.like("SID", filter.get("SID")).between("create_time", filter.get("start_date"), filter.get("end_date"))
        );

        return new PageUtils(page);
    }

}